﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;

namespace ShevaEngine2ContentPipeline.Common
{
    /// <summary>
    /// Comparer for two Vertex Declaration Contents.
    /// </summary>
    public class VertexDeclarationEqualityComparer : IEqualityComparer<VertexDeclarationContent>
    {
        /// <summary>
        /// Metoda porovna dve vertex declaration
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public bool Equals(VertexDeclarationContent x, VertexDeclarationContent y)
        {
            if (x.VertexStride == y.VertexStride)
            {
                if (x.VertexElements.Count == y.VertexElements.Count)
                {
                    for (int i = 0; i < x.VertexElements.Count; i++)
                        if (x.VertexElements[i] != y.VertexElements[i])
                            return false;

                    return true;
                }
            }

            return false;
        }

        /// <summary>
        /// Get hash code.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int GetHashCode(VertexDeclarationContent obj)
        {
            return base.GetHashCode();
        }
    }
}
